pub fn convert_base(num_str: &str, to_base: u32) -> String {
    if to_base < 2 || to_base > 16 {
        panic!("Base must be between 2 and 16");
    }

    let num_str = num_str.trim();

    // 分割数字和进制
    let parts: Vec<&str> = num_str.split('(').collect();
    let number = parts[0];
    let scale: u32 = parts[1][..parts[1].len() - 1]
        .parse()
        .expect("Invalid scale");

    // 将输入的数字从指定进制转换为十进制
    let decimal_value =
        u32::from_str_radix(number, scale).expect("Invalid number for the given base");


    // 将十进制值转换为目标进制
    let mut result = Vec::new(); 
    let mut value = decimal_value;

    while value > 0 {
        let remainder = value % to_base;
        result.push(format!("{:x}", remainder));
        value /= to_base;
    }

    // 反转结果并连接成字符串1111
    result.reverse();
    result.join("")
}
